<?php
$page = 'Team';
$in_site = 'dassnfu';
$loginVereist = 1;
$overigeVariabelen['paginaNietAf'] = true;
include_once($_SERVER['DOCUMENT_ROOT']."/start.php");

//Ben je wel ingelogd?
if(empty($spelerId)) {
	include_once($_SERVER['DOCUMENT_ROOT']."/header.php");
	include_once($_SERVER['DOCUMENT_ROOT']."/sidebar.php");
	echo "<div id='main'><div id='submain'><div class='content'><div class='subcontent'>
		<div class='content_header'><h1>Agenda</h1></div>
		<div class='content_main'>";
	echo "<div class='error'><p class='icon'>Login om deze pagina te bekijken.</p></div>";
	echo "</div></div></div></div></div>";	//content_main, sub_content, content, sub_main, main
	include_once($_SERVER['DOCUMENT_ROOT']."/footer.php");
	die();
}
//Heb je wel het recht om deze pagina te bekijken?
if(($_SESSION['rechten'] & (1 << 19)) == 0) {
	include_once($_SERVER['DOCUMENT_ROOT']."/header.php");
	include_once($_SERVER['DOCUMENT_ROOT']."/sidebar.php");
	echo "<div id='main'><div id='submain'><div class='content'><div class='subcontent'>
		<div class='content_header'><h1>Agenda</h1></div>
		<div class='content_main'>";
	echo "<div class='error'><p class='icon'>Je hebt niet het recht om deze pagina te bekijken.</p></div>";
	echo $_SESSION['rechten'];
	echo "</div></div></div></div></div>";	//content_main, sub_content, content, sub_main, main
	include_once($_SERVER['DOCUMENT_ROOT']."/footer.php");
	die();
}

$bestanden = "<link rel='stylesheet' type='text/css' href='/bestanden/css/style_tabellen".$style_nmr.".css' />
<!-- Popup -->
<link rel='stylesheet' type='text/css' href='/bestanden/js/popup/css/popup".$style_nmr.".css' />
<script type='text/javascript' src='/bestanden/js/popup/js/popup.js'></script>
<!-- Qtip -->
<link rel='stylesheet' type='text/css' href='/bestanden/js/qtip/css/jquery.qtip".$style_nmr.".css' />
<script type='text/javascript' src='/bestanden/js/qtip/js/jquery.qtip.min.js'></script>
<script type='text/javascript' src='/bestanden/js/qtip/js/standard_initialize.js'></script>
<script type='text/javascript'>
$(document).ready(function() {
	$('#popup_close, #popup').click(function(event) {
		if(event.target.id == 'popup' || event.target.id == 'popup_close') { 	
			$('body').removeClass('noscroll');
			$('#popup').hide();
		}
	});
});
</script>";
	
include_once($_SERVER['DOCUMENT_ROOT']."/php_functions/database_connectie.php");
include_once($_SERVER['DOCUMENT_ROOT']."/php_functions/instellingen.php");
include_once($_SERVER['DOCUMENT_ROOT']."/header.php");
include_once($_SERVER['DOCUMENT_ROOT']."/sidebar.php");

echo "<div id='popup' ".(isset($_POST['i']) ? "style='display: block'" : "").">";
echo "<div id='popup_page'>";
echo "<div id='popup_content'>";
if(isset($_POST['i'])) {
	echo $_POST['i'];
}
echo "</div>";
echo "</div>";
echo "<div id='popup_close'></div>";
echo "</div>";
?>
<div id="main">
<div id="submain">
<div class="content">
<div class="subcontent">
<div class="content_header">
<h1>Teaminstellingen</h1>
</div>
<div class="content_main">
<div class="selecties">
<table class="selecties">
<?php
$alles_goed = true;

$result = mysql_query("SELECT DISTINCT Team.teamId, Team.team
		FROM Teambeheer, Team
		WHERE Teambeheer.spelerId = '".$_SESSION['spelerId']."' AND Teambeheer.rechten & (b'1' << 19) AND Teambeheer.van <= NOW() AND (Teambeheer.tot >= NOW() OR Teambeheer.tot IS NULL)
			AND Team.teamId = Teambeheer.teamId
		ORDER BY Team.team");
$team = team_selecteren($result, "./instellingen.php?", true, (isset($_GET['team']) ? $_GET['team'] : null));
if($team == -1) {	echo "<div class='error'><p class='icon'>Je speelt of coach dit jaar niet bij een team.</p></div>";		$alles_goed = false;}
echo "</table>";
echo "</div>";

//Content scheiding
echo "<div class='content_scheiding'></div>";

if($alles_goed == true) {
	//Instellingen opvragen
	$result = mysql_query("SELECT DISTINCT Teaminstellingen.teaminstellingenId, Teaminstellingen.*
		FROM Teambeheer, Team, Teaminstellingen
		WHERE Teaminstellingen.teamId = ".$team."
			AND Teaminstellingen.seizoen = ".date('Y')."
			AND Teambeheer.teamId = Teaminstellingen.teamId
			AND Teambeheer.spelerId = ".$_SESSION['spelerId']." AND Teambeheer.rechten & (b'1' << 19) AND Teambeheer.van <= NOW() AND (Teambeheer.tot >= NOW() OR Teambeheer.tot IS NULL)");
	if($result <> null && mysql_num_rows($result) > 0) {
		$color = false;
		$row = mysql_fetch_object($result);
		
		//Maak de tabel aan
		echo "<table class='content left_align'>";
			//Wat mogen de teamleden?
			echo "<tr class='normaal".($color ? " alternate" : "")."'>";	($color ? $color = false : $color = true);
				echo "<td class='title no_padding center_align' colspan='2'>Wat mogen de teamleden?</td>";
			echo "</tr>";
			//Mogen spelers de opstelling bekijken voordat de wedstrijd gespeeld is
			echo "<tr class='normaal".($color ? " alternate" : "")."'>";	($color ? $color = false : $color = true);
				echo "<td><span class='icon_font in_table selectable'>".($row->teamleden & 1 ? "&#x41;" : "&#x42;")."</span></td>";
				echo "<td class='padding'>Opstelling bekijken voordat de wedstrijd gespeeld is</td>";
			echo "</tr>";
			//Mogen spelers de opstelling bekijken nadat de wedstrijd gespeeld is
			echo "<tr class='normaal".($color ? " alternate" : "")."'>";	($color ? $color = false : $color = true);
				echo "<td><span class='icon_font in_table selectable'>".($row->teamleden & 2 ? "&#x41;" : "&#x42;")."</span></td>";
				echo "<td class='padding'>Opstelling bekijken nadat de wedstrijd gespeeld is</td>";
			echo "</tr>";
			//Statistieken bekijken (ook al is bij de statistieken 'statistieken zichtbaar' aangevinkt) 
			echo "<tr class='normaal".($color ? " alternate" : "")."'>";	($color ? $color = false : $color = true);
				echo "<td><span class='icon_font in_table selectable'>".($row->teamleden & 4 ? "&#x41;" : "&#x42;")."</span></td>";	
				echo "<td class='padding'>Statistieken bekijken (ook al is bij de statistieken 'statistieken zichtbaar' aangevinkt)</td>";
			echo "</tr>";
			//Afmeldingen bekijken
			echo "<tr class='normaal".($color ? " alternate" : "")."'>";	($color ? $color = false : $color = true);
				echo "<td><span class='icon_font in_table selectable'>".($row->teamleden & 8 ? "&#x41;" : "&#x42;")."</span></td>";	
				echo "<td class='padding'>Afmeldingen bekijken</td>";
			echo "</tr>";
			
			//Wat mogen niet ingelogde bezoekers bekijken?
			echo "<tr class='normaal".($color ? " alternate" : "")."'>";	($color ? $color = false : $color = true);
				echo "<td class='title center_align' colspan='2'>Wat mogen niet ingelogde bezoekers bekijken?</td>";
			echo "</tr>";
			//Wedstrijden
			echo "<tr class='normaal".($color ? " alternate" : "")."'>";	($color ? $color = false : $color = true);
				echo "<td><span class='icon_font in_table selectable'>".($row->nietIngelogden & 1 ? "&#x41;" : "&#x42;")."</span></td>";	
				echo "<td class='padding'>Wedstrijden</td>";
			echo "</tr>";
			//Statistieken
			echo "<tr class='normaal".($color ? " alternate" : "")."'>";	($color ? $color = false : $color = true);
				echo "<td><span class='icon_font in_table selectable'>".($row->nietIngelogden & 2 ? "&#x41;" : "&#x42;")."</span></td>";	
				echo "<td class='padding'>Statistieken</td>";
			echo "</tr>";
			//Trainingen
			echo "<tr class='normaal".($color ? " alternate" : "")."'>";	($color ? $color = false : $color = true);
				echo "<td><span class='icon_font in_table selectable'>".($row->nietIngelogden & 4 ? "&#x41;" : "&#x42;")."</span></td>";
				echo "<td class='padding'>Trainingen</td>";
			echo "</tr>";
			//Activiteiten
			echo "<tr class='normaal".($color ? " alternate" : "")."'>";	($color ? $color = false : $color = true);
				echo "<td><span class='icon_font in_table selectable'>".($row->nietIngelogden & 8 ? "&#x41;" : "&#x42;")."</span></td>";
				echo "<td class='padding'>Activiteiten</td>";
			echo "</tr>";
			//Kalender
			echo "<tr class='normaal".($color ? " alternate" : "")."'>";	($color ? $color = false : $color = true);
				echo "<td><span class='icon_font in_table selectable'>".($row->nietIngelogden & 16 ? "&#x41;" : "&#x42;")."</span></td>";
				echo "<td class='padding'>Kalender</td>";
			echo "</tr>";
			//Berichten
			echo "<tr class='normaal".($color ? " alternate" : "")."'>";	($color ? $color = false : $color = true);
				echo "<td><span class='icon_font in_table selectable'>".($row->nietIngelogden & 32 ? "&#x41;" : "&#x42;")."</span></td>";	
				echo "<td class='padding'>Berichten</td>";
			echo "</tr>";
			//Reacties op berichten
			echo "<tr class='normaal".($color ? " alternate" : "")."'>";	($color ? $color = false : $color = true);
				echo "<td><span class='icon_font in_table selectable'>".($row->nietIngelogden & 64 ? "&#x41;" : "&#x42;")."</span></td>";
				echo "<td class='padding'>Reacties op berichten</td>";
			echo "</tr>";
			//Kantinediensten
			echo "<tr class='normaal".($color ? " alternate" : "")."'>";	($color ? $color = false : $color = true);
				echo "<td><span class='icon_font in_table selectable'>".($row->nietIngelogden & 128 ? "&#x41;" : "&#x42;")."</span></td>";	
				echo "<td class='padding'>Kantinediensten</td>";
			echo "</tr>";
			//Scheidsschema
			echo "<tr class='normaal".($color ? " alternate" : "")."'>";	($color ? $color = false : $color = true);
				echo "<td><span class='icon_font in_table selectable'>".($row->nietIngelogden & 256 ? "&#x41;" : "&#x42;")."</span></td>";	
				echo "<td class='padding'>Scheidsschema</td>";
			echo "</tr>";
			//Afmeldingen
			echo "<tr class='normaal".($color ? " alternate" : "")."'>";	($color ? $color = false : $color = true);
				echo "<td><span class='icon_font in_table selectable'>".($row->nietIngelogden & 512 ? "&#x41;" : "&#x42;")."</span></td>";	
				echo "<td class='padding'>Afmeldingen</td>";
			echo "</tr>";
			
			//Voorkeur instellingen
			echo "<tr class='normaal".($color ? " alternate" : "")."'>";	($color ? $color = false : $color = true);
				echo "<td class='title center_align' colspan='2'>Voorkeur instellingen</td>";
			echo "</tr>";
			//Statistieken zichtbaar voor teamleden
			echo "<tr class='normaal".($color ? " alternate" : "")."'>";	($color ? $color = false : $color = true);
				echo "<td><span class='icon_font in_table selectable'>".($row->voorkeuren & 1 ? "&#x41;" : "&#x42;")."</span></td>";	
				echo "<td class='padding'>Statistieken zichtbaar voor teamleden</td>";
			echo "</tr>";
		echo "</table>";
	}else {
		echo "<div class='information'><p class='icon'>Er zijn nog geen teaminstellingen opgegevens, vandaar dat de standaard waardes gebruikt worden.</p></div>";
		//Maak de tabel aan
		$color = true;
		echo "<table class='met_border'>";
			echo "<tr class='normaal".($color ? "" :  " alternate")."'>";
				echo "<td colspan='2' class='top_border bottom_border'>Zichtbaar voor niet ingelogden</td>";
			echo "</tr>";
			($color ? $color = false : $color = true);
			echo "<tr class='normaal".($color ? "" : " alternate")."'>";
				echo "<td style='text-align: left;'>Wedstrijdschema:</td>";
				echo "<td>NEE</td>";
			echo "</tr>";
			($color ? $color = false : $color = true);
			echo "<tr class='normaal".($color ? "" : " alternate")."'>";
				echo "<td style='text-align: left;'>Statistieken:</td>";
				echo "<td>NEE</td>";
			echo "</tr>";
		echo "</table>";
	}
}
echo "</div></div></div></div></div>";	//content_main, subcontent, content, submain, main
include_once($_SERVER['DOCUMENT_ROOT']."/footer.php");
?>